package com.yanqu.road.server.cmd.player;

import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.pb.manor.ManorProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @author ：zfr
 * @date ：2021/6/8 15:16
 */
@Cmd(code = CrossProtocol.C_CROSS_VISIT_PLAYER_MANOR, desc = "跨服拜访其他玩家庄园")
public class CrossVisitPlayerManorCmd extends CrossCommand {
    private long otherPlayerId;
    private long otherPlayerServerId;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        ManorProto.ManorVisitOtherReqMsg msg = ManorProto.ManorVisitOtherReqMsg.parseFrom(packet.getBytes());
        otherPlayerId = msg.getUserId();
        otherPlayerServerId = msg.getServerId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        ManorProto.CrossVisitOtherManorReqMsg.Builder reqMsg = ManorProto.CrossVisitOtherManorReqMsg.newBuilder();
        reqMsg.setOriginPlayerId(packet.getPlayerId());
        reqMsg.setOriginServerId(serverId);
        reqMsg.setVisitPlayerId(otherPlayerId);
        YanQuMessage message = YanQuMessageUtils.buildMessage(GameProtocol.S_MANOR_CROSS_VISIT_MANOR, reqMsg);
        MessageHelper.sendPacket(otherPlayerServerId, 0, message);
    }

    @Override
    public void sendData() {

    }
}
